<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');
if($_POST['act']=='edit'){
	$edid=getnums($_POST['edid'],0);
	$arr['title']=checkstr(trim($_POST['atname']));
	$arr['attype']=checkstr(trim($_POST['attype']));
	$arr['art_time']=strtotime($_POST['attime']);
	$arr['is_on_top']=intval($_POST['atding']);
	$arr['is_show']=intval($_POST['atshow']);
	$arr['view_times']=getnums(trim($_POST['atci']),0);
	$arr['author']=checkstr(trim($_POST['atrel']));
	$arr['content']=addslashes(trim($_POST['editor01']));

	if(empty($arr['title'])) show_automsg('请输入文章标题',$GLOBALARR['curl'],1);
	if(empty($arr['content'])) show_automsg('请输入文章内容',$GLOBALARR['curl'],1);

	$db->query('select * from ld_article where id='.$edid,2);
	if(empty($db->rs)){
		show_automsg('找不到此文章！',YMCURL.'articlelist',1);
	}else{
		$title=$db->rs["title"];
	}
	$sql=getupdatesql($arr,'ld_article',' id='.$edid,'attype,is_on_top,view_times');
	$db->sitedbexec($sql);
	record_log('编辑文章:'.$title.',id为'.$edid);
	show_automsg('编辑文章成功！',YMCURL."articlelist");
}

$edid=getnums($_GET['edid'],0);

$db->query('select * from ld_article where id='.$edid,2);
if(empty($db->rs)){
	show_automsg('找不到此文章！',YMCURL.'articlelist',1);
}


echo '<h3>文章编辑</h3>';
echo '    <script type="text/javascript" charset="utf-8" src="tedit/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="tedit/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="tedit/lang/zh-cn/zh-cn.js"></script>';

echo '<div class="main-r-body"><form method="post" action="'.geturl().'">
		<div class="main-r-item"><a href="'.YMCURL.'articlelist" class="thabtn">返回文章列表</a><input type="submit" class="thabtn" value="修改"></div>
		<input type="hidden" name="act" value="edit"><input type="hidden" name="edid" value="'.$db->rs['id'].'">';
echo '<table class="tregtab ttab hqu1">';
echo '	<tr>
			<td class="wdb20 alignr paddingr">文章标题</td>
			<td class="alignl paddingl"><input type="text" name="atname" value="'.$db->rs['title'].'" class="thconfig wd400"></td>
		</tr>';
echo '	<tr>
			<td class="wdb20 alignr paddingr">文章类型</td>
			<td class="alignl paddingl">'.getatricletype(array(3,$db->rs['atttype'])).'</td>
		</tr>';	
echo '	<tr>
			<td class="wdb20 alignr paddingr">是否置顶</td>
			<td class="alignl paddingl">'.tradio(array('atding',$db->rs['is_on_top']),3).'</td>
		</tr>';	
echo '	<tr>
			<td class="wdb20 alignr paddingr">是否显示</td>
			<td class="alignl paddingl">'.tradio(array('atshow',$db->rs['is_show']),1).'</td>
		</tr>';	
echo '	<tr>
			<td class="wdb20 alignr paddingr">浏览次数</td>
			<td class="alignl paddingl"><input type="text" name="atci" value="'.$db->rs['view_times'].'" class="thconfig wd400"></td>
		</tr>';
echo '	<tr>
			<td class="wdb20 alignr paddingr">发布人</td>
			<td class="alignl paddingl"><input type="text" name="atrel" value="'.$db->rs['author'].'" class="thconfig wd400"></td>
		</tr>';	
echo '	<tr>
			<td class="wdb20 alignr paddingr">发布时间</td>
			<td class="alignl paddingl"><input type="text" name="attime" value="'.formatdate($db->rs['art_time']).'" class="thconfig wd400"></td>
		</tr>';								
echo '</table>';
echo '<table class="hqu2" >';
echo '	<tr>
			<td>
                        <div class = "editor">
                    <textarea rows="10" cols="20" name="editor01" id="editor01">'.$db->rs['content'].'</textarea>
                    </div>
                        
                         </td>
		</tr>';						
echo '</table>';

echo '</form></div>';

?>
<script type="text/javascript">
var ue = UE.getEditor('editor01',{
	initialFrameWidth:1000,
	initialFrameHeight:400
});
</script>